<?php

/**
 * Description of AzureCelebInit
 *
 * @author honza
 */

namespace Celebrio\FileSystem\Drivers;

use Nette\Object;
use \dibi;

use Celebrio\Core\IModuleInit;
use \Celebrio\Core\DummyInit;
use Celebrio\Core\DDL;
use Celebrio\FileSystem\Drivers\AzureStorageDriver;
use Celebrio\Core\ServiceProvider;
use Celebrio\FileSystem\IOException;
use Celebrio\FileSystem\Drivers\AzureCelebrio;
use \InvalidStateException;
use \InvalidArgumentException;


class AzureCelebrioInit extends DummyInit implements IModuleInit {
    
    public function changeConfig(array $configuration) {
        return $configuration;
    }


    public function init(array $configuration) {//        AzureCelebrio::setConnectionSettings($accountName, $password);

    }

    public function install(array $configuration) {
        parent::install($configuration);
        $this->initDriverStorage();
        
    }
    
    public function uninstall() {
        parent::uninstall();
        dibi::query("
                DELETE FROM [files_storages]
                WHERE [name_files_storage] = %s", "azureCelebrio");
    }

    public function isAvailable() {
        return true;
    }
    
    private function initDriverStorage() {
        $exists = dibi::fetch("
            SELECT [id_files_storage] 
            FROM [files_storages]
            WHERE [name_files_storage] = %s", "azureCelebrio");
        
        if(!$exists) {
            dibi::query("
                INSERT INTO [files_storages]
                ([name_files_storage]) VALUES (%s)", "azureCelebrio");
        }
    }

}
